import { S } from '../../s';
import { IPSControlAttribute } from '../ipscontrol-attribute';
import { IPSControlLogic } from '../ipscontrol-logic';
import { IPSControlRender } from '../ipscontrol-render';
import { IPSDEListItem } from './ipsdelist-item';
import { IPSDEUIActionGroup } from '../../dataentity/uiaction/ipsdeuiaction-group';
import { IPSLanguageRes } from '../../res/ipslanguage-res';
import { IPSSysPFPlugin } from '../../res/ipssys-pfplugin';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEListItemImpl
  extends PSModelObjectImpl
  implements IPSDEListItem
{
  get align(): 'LEFT' | 'CENTER' | 'RIGHT' {
    return this.M.align;
  }

  get cLConvertMode(): 'NONE' | 'FRONT' | 'BACKEND' {
    return this.M.cLConvertMode;
  }

  protected cappslanguageres: IPSLanguageRes;
  getCapPSLanguageRes(): IPSLanguageRes | null {
    return (
      this.cappslanguageres ||
      (this.cappslanguageres = this.fillObjectModel(
        S._276,
        this.M.getCapPSLanguageRes,
        S._2a8,
      ) as IPSLanguageRes)
    );
  }

  get caption(): string {
    return this.M.caption;
  }

  get dataItemName(): string {
    return this.M.dataItemName;
  }

  get groupItem(): string {
    return this.M.groupItem;
  }

  get itemPrivId(): string {
    return this.M.itemPrivId;
  }

  get itemType(): 'TEXTITEM' | 'ACTIONITEM' | 'DATAITEM' {
    return this.M.itemType;
  }

  protected pscontrolattributes: IPSControlAttribute[];
  getPSControlAttributes(): IPSControlAttribute[] | null {
    return (
      this.pscontrolattributes ||
      (this.pscontrolattributes = this.fillChildListModel(
        this.M.getPSControlAttributes,
        S._3f5,
      ) as IPSControlAttribute[])
    );
  }

  findPSControlAttribute(objKey: any): IPSControlAttribute | null {
    return this.getPSModel5(
      S._3f5,
      this.getPSControlAttributes(),
      objKey,
    ) as IPSControlAttribute;
  }

  protected pscontrollogics: IPSControlLogic[];
  getPSControlLogics(): IPSControlLogic[] | null {
    return (
      this.pscontrollogics ||
      (this.pscontrollogics = this.fillChildListModel(
        this.M.getPSControlLogics,
        S._38d,
      ) as IPSControlLogic[])
    );
  }

  findPSControlLogic(objKey: any): IPSControlLogic | null {
    return this.getPSModel5(
      S._38d,
      this.getPSControlLogics(),
      objKey,
    ) as IPSControlLogic;
  }

  protected pscontrolrenders: IPSControlRender[];
  getPSControlRenders(): IPSControlRender[] | null {
    return (
      this.pscontrolrenders ||
      (this.pscontrolrenders = this.fillChildListModel(
        this.M.getPSControlRenders,
        S._3f6,
      ) as IPSControlRender[])
    );
  }

  findPSControlRender(objKey: any): IPSControlRender | null {
    return this.getPSModel5(
      S._3f6,
      this.getPSControlRenders(),
      objKey,
    ) as IPSControlRender;
  }

  protected psdeuiactiongroup: IPSDEUIActionGroup;
  getPSDEUIActionGroup(): IPSDEUIActionGroup | null {
    return (
      this.psdeuiactiongroup ||
      (this.psdeuiactiongroup = this.fillObjectModel(
        S._20f,
        this.M.getPSDEUIActionGroup,
        S._2e6,
      ) as IPSDEUIActionGroup)
    );
  }

  protected renderpssyspfplugin: IPSSysPFPlugin;
  getPSSysPFPlugin(): IPSSysPFPlugin | null {
    return (
      this.renderpssyspfplugin ||
      (this.renderpssyspfplugin = this.fillObjectModel(
        S._27c,
        this.M.getPSSysPFPlugin,
        S._2a7,
      ) as IPSSysPFPlugin)
    );
  }

  get valueFormat(): string {
    return this.M.valueFormat;
  }

  get width(): number {
    return this.M.width;
  }

  get widthString(): string {
    return this.M.widthString;
  }

  get enableItemPriv(): boolean {
    return this.M.enableItemPriv != null ? this.M.enableItemPriv : false;
  }

  get enableSort(): boolean {
    return this.M.enableSort;
  }

  get hiddenDataItem(): boolean {
    return this.M.hiddenDataItem != null ? this.M.hiddenDataItem : false;
  }
  get cls(): string {
    return 'PSDEListItemImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._d9) return true;
    return super.instanceof(cls);
  }
}
